// 2025/3/25
// 字母收集

#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
    int m, n; cin >> m >> n;
    vector<string> matrix(m);
    vector<vector<int>> score(m, vector<int>(n, 0));
    unordered_map<char, int> values = {{'l', 4}, {'o', 3}, {'v', 2}, {'e', 1}};
    for(auto& str : matrix) cin >> str;
    score[0][0] = values[matrix[0][0]];
    for(int i = 1; i < m; i++)
        score[i][0] = score[i - 1][0] + values[matrix[i][0]];
    for(int j = 1; j < n; j++)
        score[0][j] = score[0][j - 1] + values[matrix[0][j]];

    for(int i = 1; i < m; i++)
    {
        for(int j = 1; j < n; j++)
        {
            score[i][j] = values[matrix[i][j]] + max(score[i - 1][j], score[i][j - 1]);
        }
    }
    cout << score[m - 1][n - 1] << endl;
}
// 64 位输出请用 printf("%lld")